﻿<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="index.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="Styles/screen.css" rel="stylesheet" type="text/css" />

    <script src="Scripts/jquery-1.6.4.js" type="text/javascript"></script>
    <%--for jquery-spin.js--%>
    <script src="Scripts/jquery-ui.min.js" type="text/javascript"></script>
    <%--使用spin-button選取數字--%>
    <script src="Scripts/jquery-spin.js" type="text/javascript"></script>
    <%--限定特定範圍的數字--%>
    <script src="Scripts/jquery.jstepper.js" type="text/javascript"></script>
    <%--限定允許輸入正負整數、浮點--%>
    <script src="Scripts/jquery.numeric.js" type="text/javascript"></script>  
    
    <%--時間選取器--%>
    <script src="Scripts/jquery.timepicker.js" type="text/javascript"></script>
    
    <%--限定特定格式--%>
    <script src="Scripts/jquery.maskedinput-1.2.2.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    
    <div>
      <table>
        <tbody>
          <tr>
            <td>日期</td>
            <td><asp:Label ID="tfDATE" runat="server" /></td>
          </tr>
          <tr>
            <td>今天的我</td>
            <td>
              <asp:FileUpload ID="PhotoUpload" runat="server" />
              <asp:CustomValidator 
                ID="CustomValidator_PhotoUpload" 
                runat="server" 
                ClientValidationFunction="ValidatePhotoUpload">
              </asp:CustomValidator>
            </td>
          </tr>
          <tr>
            <td>體重</td>
            <td><asp:TextBox ID="tfWEIGHT" CssClass="numeric min_0__max_99 spin_button_interval01_min_0__max_99" runat="server" /></td>
          </tr>
          <tr>
            <td>腰圍</td>
            <td><asp:TextBox ID="tfWAISTLINE" CssClass="numeric min_0__max_99 spin_button_interval01_min_0__max_99" runat="server" /></td>
          </tr>
          <tr>
            <td>跑步公里數</td>
            <td><asp:TextBox ID="tfRUNNING_MILEAGE" CssClass="numeric min_0__max_99 spin_button_interval01_min_0__max_99" runat="server" /></td>
          </tr>
          <tr>
            <td>伏地體伸數</td>
            <td><asp:TextBox ID="tfPRESS_UP_TIME" CssClass="numeric min_0 spin_button_interval1_min_0" runat="server" /></td>
          </tr>
          <tr>
            <td>仰臥起坐數</td>
            <td><asp:TextBox ID="tfSITUP_TIME" CssClass="numeric min_0 spin_button_interval1_min_0" runat="server" /></td>
          </tr>
          <tr>
            <td>抽煙數</td>
            <td><asp:TextBox ID="tfSMOKED_CIGARETTES_NUMBER" CssClass="numeric min_0 spin_button_interval1_min_0" runat="server" /></td>
          </tr>
          <tr>
            <td>睡覺時間</td>
            <td><asp:TextBox ID="tfSLEEP_TIME" CssClass="timepicker" runat="server" /></td>
          </tr> 
                   
        </tbody>
      </table>
      <hr />
      <asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" />
      <hr />
    </div>
    
    <script src="Scripts/index.js" type="text/javascript"></script>
    <script type="text/javascript">
      function ValidatePhotoUpload(source, args) {
        var PhotoUpload = document.getElementById('<%= PhotoUpload.ClientID %>');
        var FileUploadPath = PhotoUpload.value;

        if (FileUploadPath == '') {
          // There is no file selected 
          source.innerText="請選擇上傳檔案";
          args.IsValid = false;
        }
        else {
          var Extension = FileUploadPath.substring(FileUploadPath.lastIndexOf('.') + 1).toLowerCase();

          if (Extension == "jpg") {
            args.IsValid = true; // Valid file type
          }
          else {
            source.innerText="上傳檔案格式必須為jpg";
            args.IsValid = false; // Not valid file type
          }
        }
      }
    </script>
    
    </form>
</body>
</html>
